
 ob_start(); 
 error_reporting(0);
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shop gau bong Ted</title>
<link href="style.css" rel="stylesheet" media="all" type="text/css"/>
<script type="text/javascript" src="banner_img/swfobject.js"></script>  
</head>


<body>
<?php
 include ('ketnoi.php');
include('php_function.php');
?>  
<?php  
        if(isset($_GET['id_sp']) != "") //  Nếu có ID truyền vào  
        {       $_SESSION['timeout'][$id_sp]=time();
		        $id_sp=$_GET['id_sp'];
                include('ketnoi.php'); 
                // Kiểm tra xem id này có trong CSDL hay k?  
                $q = mysql_query("SELECT MA_SP FROM sanpham WHERE MA_SP in ('$id_sp')");  
                $num_q = mysql_num_rows($q);
				 
                // Nếu tồn tại  
                if($num_q == 1)  
                {      
						
                        //session_register("giohang");  
                        //  nếu id này có trong giỏ hàng rồi  
                        if(isset($_SESSION['giohang'][$id_sp]))  
                        {       
                                // Tăng số lượng nó lên  
                                $_SESSION['giohang'][$id_sp] ++;	
								
                        }  
                        else // Chưa có trong giỏ hàng (mới chọn)  
                        {  
                                $_SESSION['giohang'][$id_sp] = 1; // Số lượng mặc định là 1  
                        }  
                       	
                }  
                else  
                {  
                        echo "<p align='center' style='font-size:18;color:red'>Không tồn tại sản phẩm này!</p>";  
                        header("refresh:3; showcart.php");  
                }   
			//echo "<a href='showcart.php'>Gio hang cua ban co ".count($_SESSION['giohang'])." san pham</a>";
        }  
       
 	
?>
	<div class="nenweb">
    	<div class="page"> 
        
        	 <div class="head"> </div>
			
             <div class="banner">
                 <div class="logo"><img src="images/logo_ted.jpg" width="100%" height="100%" alt="logo_ted"/></div>
                 <div class="banner_left">
              <div class="nendangnhap">
			  <?php
			 
			  if(isset($_SESSION['username']))
			  {
			 
					$sql="select * from khachhang where TAIKHOAN_KH='".$_SESSION['username']."'";
												$query=mysql_query($sql) or die("can't query");
												while($row=mysql_fetch_array($query))
												{
												echo "Chào<em> ".$row['TEN_KH']."</em> | "; 
												echo "<a href='thoat.php'>Thoát</a> | " ;
												$_SESSION['email']=$row['EMAIL_KH'];
												$_SESSION['hoten']=$row['TEN_KH'];
												$_SESSION['sdt']=$row['SODT_KH'];
												$_SESSION['diachi']=$row['DIACHI_KH'];
												} 
					
			  }
			  else {
			 	echo "<a href='login.php'>Đăng nhập</a>&nbsp;|&nbsp;<a href='register.php'>Đăng ký</a> |";
				}
				
				echo "<a href='showcart.php' class='cart'>Giỏ hàng<span>";
				if(isset($_SESSION['giohang'])) {
				echo count($_SESSION['giohang']);
				}
				echo "</span></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp";
				
				
				?> 
                    </div><!--nendangnhap-->
                    <div class="showimg"><img src="images/banner144.png" width="100%" height="100%" alt="logo_ted"/>
                    </div>
                    
               </div><!--BANNER_LEFT-->
             </div><!--BANNER-->
             
             <div id="menu">
             	<ul>
                	<li><a href="index.php">TRANG CHỦ</a>
                    <li><a href="#">GẤU BÔNG</a>
                    	<ul class="submenu">
                        	<li><a href="#">CHÓ BÔNG</a></li>
                            <li><a href="#">MÈO BÔNG</a></li>
                            <li><a href="#">HEO BÔNG</a></li>
                             <li><a href="#">THÚ NHỒI BÔNG KHÁC</a></li>
                        </ul></li>
                    <li><a href="#">HOA GẤU BÔNG</a>
                    <li><a href="#">TIN TỨC</a>
                    <li><a href="huongdanthanhtoan.php">HƯỚNG DẪN THANH TOÁN</a>
                    <li><a href="lienhe.php">LIÊN HỆ</a>
                </ul>
             </div>
			 <div class="show" >
             	 <p id="flashcontent"><script type="text/javascript">  
					var so = new SWFObject("banner_img/banner.swf", "mymovie", "970", "220", "8");  
					so.addParam("menu", "false");  
					so.write("flashcontent"); 
                 </script></p>
             </div>
		  <div class="nentimkiem" >
		  
				 <form action="tim kiem.php"  method="post">
				 &nbsp;&nbsp;&nbsp; <input align="absmiddle" width="20px" height="20px" type="image" src="images\tim.jpg"  />
			  	<label style="color:#FF6633; font-size:16px; font-weight:bold">TÌM TÊN SẢN PHẨM</label>&nbsp;&nbsp;&nbsp;<input type="text" name="tensp" />
				&nbsp;&nbsp;&nbsp;<label style="color:#FF6633; font-size:16px; font-weight:bold">TÌM GIÁ SẢN PHẨM</label>&nbsp;&nbsp;&nbsp;<select name="gia" style="width:180px" onclick="submitCboSemester();">
				   <option value="" >Chọn giá sản phẩm</option>
				   <option value="1">Dưới 100000 VND</option>
				   <option value="2">từ 10000 đến dưới 300000 VND</option>
				   <option value="3">từ 300000 đến dưới 500000 VND</option>
				   <option value="4">từ 500000 VND trở lên </option>
				 
					 </select>
			 <button style="background:#FFCC99" class="button">
			 <span><span>Tìm kiếm</span></span></button>
	
	   </form>
		 </div><!--nentimkiem--><?php
	                date_default_timezone_set('Asia/Ho_Chi_Minh');
					$now = getdate(); 
					$currentTime=date('Y-m-d', time());	
					include('ketnoi.php');
					$sql2= "select * from dot_km where MADOT_KM='ggsp' ";
					
					$query=mysql_query($sql2) or die ("can't not query 2");
					$row2 = mysql_fetch_array($query);
	
					$ngaybd=$row2[2];
			        $ngaykt=$row2[3];
					
	 		if(($ngaybd <= $currentTime) && ($currentTime<=$ngaykt)){
	         echo "<div class=\"spkm\">";//<!--sp khuyen mai-->
             	echo "<img src=\"images/thangngang_km5.png\" width=\"970\" height=\"46\" alt=\"Sản phẩm mới\"/>
				<div class=\"nd_km\">";
				
					
					
					$sql1= "select * from sanpham AS a, giamgia_sp AS b, dongia AS c, dot_km AS d,thongso_sp AS e,ct_sanpham as ct
							where a.MA_SP=b.MA_SP
							and a.MA_SP=c.MA_SP
							and b.MADOT_KM=d.MADOT_KM
							and e.MA_TSSP=ct.MA_TSSP
							and a.MA_SP=ct.MA_SP
							and a.TRANGTHAI_KM='1' 
							and b.MADOT_KM='ggsp' ";
					$result1=mysql_query($sql1) or die ("can't km");
					echo"<table  border=0  align='center' stype='margin-left:'20''  >";

					$i=0;
					while($row1 = mysql_fetch_array($result1)){
					$i++;
					echo "<td class=bg_sp_tc>";	
					echo "<div class='ctiet_sp'>";
					echo "<img src='viewimg1.php?stt=".$row1['MA_SP']."' width='180px' height='160px' />"; 
					echo "<a href=chitiet_sp.php?ma_sp=$row1[MA_SP]><div class='chitiet_sp'>
					Tên:".$row1['TEN_SP']." <br/>
					Kích cỡ: ".$row1['KICHCO']." <br/>
					Màu sắc: ".$row1['MAUSAC']." <br/>
					Xuất xứ: ".$row1['XUATXU']." <br/>
					Giảm: <font color='#FF6633'>".$row1['PHANTRAMGIAM']."%</font>
					</div></a>";
					
					echo"<center>";echo"<font size='+1.2' color='#FF158A' '>".$row1['TEN_SP']." ";echo"</center>";
					echo"<center>";echo"<font size='+1.2'  color='RED''>".VndDot(floor($row1['GIATHANH_SP']*(1-($row1['PHANTRAMGIAM'])/100)))." VNĐ";echo"</font></center>";
					echo"<center>";echo"<font size='+0.8'  color='RED' style='text-decoration: line-through' '>".VndDot($row1['GIATHANH_SP'])." VNĐ";echo"</font></center>";
					echo"<center>";echo"<font size='+1.2'  color='#FF9933' '><img src='images/icon_li.png' width='10' height='9'/> ".$row1['DIENGIAI_SP']."! ";echo"</center>";
					
					echo "<a href=chitiet_sp.php?ma_sp=$row1[MA_SP] class='chitiet'><font color='white' '>Xem chi tiết</font></a> <a class='button' href=index.php?id_sp=$row1[MA_SP]><span><span>Mua hàng</span></span></a>"; 
					echo "</div>";
					
					
					echo"</td>";
					
					if($i%4==0)
					{
					echo "<tr>";
					echo "</tr>";
					}
					
					}
					
					echo"</table>";
					
				
				echo "</div>";//<!--nd_km-->
			 echo "</div>";//<!--sp khuyen mai-->
			 }
			 ?>
             <div class="spmoi">
             	<img src="images/title_block_new_product.jpg" width="970" height="46" alt="Sản phẩm mới"/>
         
			 <?php
include('ketnoi.php');

$sql = "SELECT *
		FROM sanpham AS sp,dongia AS dg, ct_sanpham as ct, thongso_sp as ts
		WHERE  sp.MA_SP=dg.MA_SP
		and sp.trangthai_sp=1
		and sp.SP_MOI=1
		and sp.MA_SP=ct.MA_SP
		and ts.MA_TSSP=ct.MA_TSSP
		and sp.TRANGTHAI_KM=0
		order by sp.MA_SP desc";
$result = mysql_query($sql);

echo"<table  border=0  align='center' stype='margin-left:'20''  >";

$i=0;
while($row = mysql_fetch_array($result)){
$i++;
echo "<td class=bg_sp_tc>";	
echo "<div class='ctiet_sp'>";
echo "<img src='viewimg1.php?stt=".$row['MA_SP']."' width='180px' height='160px' />"; 
echo "<a href=chitiet_sp.php?ma_sp=$row[MA_SP]><div class='chitiet_sp'>
Tên:".$row['TEN_SP']." <br/>
Kích cỡ: ".$row['KICHCO']." <br/>
Màu sắc: ".$row['MAUSAC']." <br/>
Xuất xứ: ".$row['XUATXU']." 
</div></a>";

echo"<center>";echo"<font size='+1.2' color='#FF158A' '>".$row['TEN_SP']." ";if($row["SP_MOI"]==1) echo "<img src='images/icon_new2.jpg' width='20px' height='15px'/>"; else;echo"</center>";
echo"<center>";echo"<font size='+1.2'  color='RED' '>".VndDot($row['GIATHANH_SP'])." VNĐ";echo"</center>";
echo"<center>";echo"<font size='+1.2'  color='#FF9933' '><img src='images/icon_li.png' width='10' height='9'/> ".$row['DIENGIAI_SP']."! ";echo"</center>";
echo "<br>";
echo "<a href=chitiet_sp.php?ma_sp=$row[MA_SP] class='chitiet'><font color='white' '>Xem chi tiết</font></a> <a class='button' href=index.php?id_sp=$row[MA_SP]><span><span>Mua hàng</span></span></a>"; 
echo "</div>";


echo"</td>";

if($i%4==0)
{
echo "<tr>";
echo "</tr>";
}

}

echo"</table>";

?>
<a class="button">button</a>

					</div><!--end_spmoi-->
                    <div class="sphot">
                    	<img src="images/title_block_hot_product.jpg" width="970" height="46" alt="Sản phẩm mới"/>
<?php
include('ketnoi.php');
$sql ="SELECT *
		FROM sanpham AS sp,dongia AS dg, ct_sanpham as ct, thongso_sp as ts
		WHERE  sp.MA_SP=dg.MA_SP
		and sp.trangthai_sp=1
		and sp.SP_MOI=0
		and sp.MA_SP=ct.MA_SP
		and ts.MA_TSSP=ct.MA_TSSP
		and sp.TRANGTHAI_KM=0
		order by sp.MA_SP desc";
$result = mysql_query($sql) or-die("cannot query!");

echo"<table  border=0  align='center' stype='margin-left:'20''  >";

$i=0;
while($row = mysql_fetch_array($result)){
$i++;
echo "<td class=bg_sp_tc>";	
echo "<div class='ctiet_sp'>";
echo "<img src='viewimg1.php?stt=".$row['MA_SP']."' width='180px' height='160px' />"; 
echo "<a href=chitiet_sp.php?ma_sp=$row[MA_SP]><div class='chitiet_sp'>
Tên:".$row['TEN_SP']." <br/>
Kích cỡ: ".$row['KICHCO']." <br/>
Màu sắc: ".$row['MAUSAC']." <br/>
Xuất xứ: ".$row['XUATXU']." 
</div></a>";

echo"<center>";echo"<font size='+1.2' color='#FF158A' '>".$row['TEN_SP']." ";if($row["SP_MOI"]==1) echo "<img src='images/icon_new2.jpg' width='20px' height='15px'/>"; else;echo"</center>";
echo"<center>";echo"<font size='+1.2'  color='RED' '>".VndDot($row['GIATHANH_SP'])." VNĐ";echo"</center>";
echo"<center>";echo"<font size='+1.2'  color='#FF9933' '><img src='images/icon_li.png' width='10' height='9'/> ".$row['DIENGIAI_SP']."! ";echo"</center>";
echo "<br>";
echo "<a href=chitiet_sp.php?ma_sp=$row[MA_SP] class='chitiet'><font color='white' '>Xem chi tiết</font></a> <a class='button' href=index.php?id_sp=$row[MA_SP]><span><span>Mua hàng</span></span></a>"; 
echo "</div>";


echo"</td>";

if($i%4==0)
{
echo "<tr>";
echo "</tr>";
}

}

echo"</table>";

?> 
                    </div><!--sphot--> 
                    <div class="footer">
                    	<center><br/>
                            <h2><font color="#FF9D3C">Shop gấu bông Ted</font></h2>
                            <h2><font color="#FF9D3C">Thực hiện: Nhóm Sinh viên trường Đại Học Cần Thơ</font><h2>
                        </center>
                    </div><!--fopter-->
			
             
        </div>	<!--page-->
    </div><!--nenweb-->
</body>
</html>
